/*
	Codes for group-comparisons results in figure5.
	Please set the working directory to the folder where the data files
	are located.
*/


//Study2 Figure 5 
log using 5_study2.log, replace

	//Panel a
		//Calculate correct response rate (percent values when "correct"=1) for each task
		insheet using study2_all_tasks.csv, clear
		tabulate correct if task=="student"
		tabulate correct if task=="ideology"
		tabulate correct if task=="voice"
		tabulate correct if task=="benefit"
		tabulate correct if task=="no-benefit"

		//Chi-Suqared Tests of correct response rates between the voice task and the student document task
		insheet using study2_voice_student.csv, clear
		tabulate task correct, chi2
		
		//Chi-Suqared Tests of correct response rates between the voice task and the ideology task
		insheet using study2_voice_ideology.csv, clear
		tabulate task correct, chi2
		
		//Chi-Suqared Tests of correct response rates between the voice task and the benefit task
		insheet using study2_voice_benefit.csv, clear
		tabulate task correct, chi2
		
		//Chi-Suqared Tests of correct response rates between the voice task and the no-benefit task
		insheet using study2_voice_no-benefit.csv, clear
		tabulate task correct, chi2
		
		//Chi-Suqared Tests of correct response rates between the benefit task and the no-benefit task
		insheet using study2_benefit_no-benefit.csv, clear
		tabulate task correct, chi2
	
	//Panel b
		//Calculate confirmation bias rate (percent values when "bias"=1) for each task
		insheet using study2_all_tasks.csv, clear
		tabulate bias if task=="student"
		tabulate bias if task=="ideology"
		tabulate bias if task=="voice"
		tabulate bias if task=="benefit"
		tabulate bias if task=="no-benefit"

		//Chi-Suqared Tests of confirmation bias rates between the voice task and the student document task
		insheet using study2_voice_student.csv, clear
		tabulate task bias, chi2
		
		//Chi-Suqared Tests of confirmation bias rates between the voice task and the ideology task
		insheet using study2_voice_ideology.csv, clear
		tabulate task bias, chi2

		//Chi-Suqared Tests of confirmation bias rates between the voice task and the benefit task
		insheet using study2_voice_benefit.csv, clear
		tabulate task bias, chi2

		//Chi-Suqared Tests of confirmation bias rates between the voice task and the no-benefit task
		insheet using study2_voice_no-benefit.csv, clear
		tabulate task bias, chi2
		
		//Chi-Suqared Tests of confirmation bias rates between the benefit task and the no-benefit task
		insheet using study2_benefit_no-benefit.csv, clear
		tabulate task bias, chi2
	
log close

